<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="common/include :: header('新增目录')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-catalog-add">
			<input id="treeId" name="parentId" type="hidden" th:value="${catalog.id}"   />
			<input id="module" name="module" type="hidden"  th:value="${module}">

			<div class="form-group">
				<label class="col-sm-3 control-label">上级目录：</label>
				<div class="col-sm-8">
				    <div class="input-group">
						<input class="form-control" type="text" onclick="selectCatalogTree()" id="treeName" readonly="true" th:value="${catalog.catalogName}">
					    <span class="input-group-addon"><i class="fa fa-search"></i></span>
				    </div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">目录名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="catalogName" id="catalogName" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">显示排序：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="orderNum" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">目录状态：</label>
				<div class="col-sm-8">
				    <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
						<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}">
						<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
					</div>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="common/include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "content/catalog";
		var module = [[${module}]];

		$("#form-catalog-add").validate({
			onkeyup: false,
			rules:{
				catalogName:{
					required:true
				},
				orderNum:{
					digits:true
				},
			},
		    focusCleanup: true
		});

		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/add", $('#form-catalog-add').serialize());
	        }
	    }

		/*目录管理-新增-选择父目录树*/
		function selectCatalogTree() {
			var options = {
				title: '目录选择',
				width: "380",
				url: prefix + "/selectCatalogTree/" + $("#treeId").val()+"-"+module,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}

		function doSubmit(index, layero){
			var body = layer.getChildFrame('body', index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
   			layer.close(index);
		}
	</script>
</body>
</html>
